package com.faithbj.common_service.service.impl;

import com.faithbj.common.model.compare.*;
import com.faithbj.common_service.dao.*;
import com.faithbj.common_service.service.CompareService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 电子比对Service实现类
 * 
 * @author chen liu
 */
@Service("compareService")
@Transactional
public class CompareServiceImpl implements CompareService {

    @Resource
    private AFMOfficalDataDao afmOfficalDao;

    @Resource
    private CivilOfficalDataDao civilOfficalDao;

    @Resource
    private HPOfficalDataDao hpOfficalDao;

    @Resource
    private IBAOfficalDataDao ibaOfficalDao;

    @Resource
    private PSOfficalDataDao psOfficalDao;

    @Resource
    private SIOfficalDataDao siOfficalDao;

    @Resource
    private TaxOfficalDataDao taxOfficalDao;

    @Override
    public AFMOfficalData getAFMOfficalData(String applicantCardNum, String applyNum) {
        String hql = "select d from AFMOfficalData as d where d.applicantCardNum=? and d.applyNum = ?";
        List<AFMOfficalData> list = afmOfficalDao.findAny(hql, new Object[] { applicantCardNum, applyNum });
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        } else {
            return null;
        }
    }

    @Override
    public CivilOfficalData getCivilOfficalData(String applicantCardNum, String applyNum) {
        String hql = "select d from CivilOfficalData as d where d.applicantCardNum=? and d.applyNum = ?";
        List<CivilOfficalData> list = civilOfficalDao.findAny(hql, new Object[] { applicantCardNum, applyNum });
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        } else {
            return null;
        }
    }

    @Override
    public HPOfficalData getHPOfficalData(String applicantCardNum, String applyNum) {
        String hql = "select d from HPOfficalData as d where d.applicantCardNum=? and d.applyNum = ?";
        List<HPOfficalData> list = hpOfficalDao.findAny(hql, new Object[] { applicantCardNum, applyNum });
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        } else {
            return null;
        }
    }

    @Override
    public IBAOfficalData getIBAOfficalData(String applicantCardNum, String applyNum) {
        String hql = "select d from IBAOfficalData as d where d.applicantCardNum=? and d.applyNum = ?";
        List<IBAOfficalData> list = ibaOfficalDao.findAny(hql, new Object[] { applicantCardNum, applyNum });
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        } else {
            return null;
        }
    }

    @Override
    public PopulationOfficalData getPSOfficalData(String applicantCardNum, String applyNum) {
        String hql = "select d from PopulationOfficalData as d where d.applicantCardNum=? and d.applyNum = ?";
        List<PopulationOfficalData> list = psOfficalDao.findAny(hql, new Object[] { applicantCardNum, applyNum });
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        } else {
            return null;
        }
    }

    @Override
    public SIOfficalData getSIOfficalData(String applicantCardNum, String applyNum) {
        String hql = "select d from SIOfficalData as d where d.applicantCardNum=? and d.applyNum = ?";
        List<SIOfficalData> list = siOfficalDao.findAny(hql, new Object[] { applicantCardNum, applyNum });
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        } else {
            return null;
        }
    }

    @Override
    public TaxOfficalData getTaxOfficalData(String applicantCardNum, String applyNum) {
        String hql = "select d from TaxOfficalData as d where d.applicantCardNum=? and d.applyNum = ?";
        List<TaxOfficalData> list = taxOfficalDao.findAny(hql, new Object[] { applicantCardNum, applyNum });
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        } else {
            return null;
        }
    }
}
